home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / BBS-Archive / Dev / gcc-2.6.3-bin.lha / GNU / info / gcc.info-9 (.txt) < prev   
GNU Info File  |  1995-03-30  |  50KB  |  851 lines

  1. This is Info file gcc.info, produced by Makeinfo-1.55 from the input
  2. file gcc.texi.
  3.    This file documents the use and the internals of the GNU compiler.
  4.    Published by the Free Software Foundation 675 Massachusetts Avenue
  5. Cambridge, MA 02139 USA
  6.    Copyright (C) 1988, 1989, 1992, 1993, 1994 Free Software Foundation,
  7.    Permission is granted to make and distribute verbatim copies of this
  8. manual provided the copyright notice and this permission notice are
  9. preserved on all copies.
  10.    Permission is granted to copy and distribute modified versions of
  11. this manual under the conditions for verbatim copying, provided also
  12. that the sections entitled "GNU General Public License," "Funding for
  13. Free Software," and "Protect Your Freedom--Fight `Look And Feel'" are
  14. included exactly as in the original, and provided that the entire
  15. resulting derived work is distributed under the terms of a permission
  16. notice identical to this one.
  17.    Permission is granted to copy and distribute translations of this
  18. manual into another language, under the above conditions for modified
  19. versions, except that the sections entitled "GNU General Public
  20. License," "Funding for Free Software," and "Protect Your Freedom--Fight
  21. `Look And Feel'", and this permission notice, may be included in
  22. translations approved by the Free Software Foundation instead of in the
  23. original English.
  24. File: gcc.info,  Node: Min and Max,  Next: Destructors and Goto,  Prev: Naming Results,  Up: C++ Extensions
  25. Minimum and Maximum Operators in C++
  26. ====================================
  27.    It is very convenient to have operators which return the "minimum"
  28. or the "maximum" of two arguments.  In GNU C++ (but not in GNU C),
  29. `A <? B'
  30.      is the "minimum", returning the smaller of the numeric values A
  31.      and B;
  32. `A >? B'
  33.      is the "maximum", returning the larger of the numeric values A and
  34.      B.
  35.    These operations are not primitive in ordinary C++, since you can
  36. use a macro to return the minimum of two things in C++, as in the
  37. following example.
  38.      #define MIN(X,Y) ((X) < (Y) ? : (X) : (Y))
  39. You might then use `int min = MIN (i, j);' to set MIN to the minimum
  40. value of variables I and J.
  41.    However, side effects in `X' or `Y' may cause unintended behavior.
  42. For example, `MIN (i++, j++)' will fail, incrementing the smaller
  43. counter twice.  A GNU C extension allows you to write safe macros that
  44. avoid this kind of problem (*note Naming an Expression's Type: Naming
  45. Types.).  However, writing `MIN' and `MAX' as macros also forces you to
  46. use function-call notation notation for a fundamental arithmetic
  47. operation.  Using GNU C++ extensions, you can write `int min = i <? j;'
  48. instead.
  49.    Since `<?' and `>?' are built into the compiler, they properly
  50. handle expressions with side-effects;  `int min = i++ <? j++;' works
  51. correctly.
  52. File: gcc.info,  Node: Destructors and Goto,  Next: C++ Interface,  Prev: Min and Max,  Up: C++ Extensions
  53. `goto' and Destructors in GNU C++
  54. =================================
  55.    In C++ programs, you can safely use the `goto' statement.  When you
  56. use it to exit a block which contains aggregates requiring destructors,
  57. the destructors will run before the `goto' transfers control.  (In ANSI
  58. C++, `goto' is restricted to targets within the current block.)
  59.    The compiler still forbids using `goto' to *enter* a scope that
  60. requires constructors.
  61. File: gcc.info,  Node: C++ Interface,  Next: Template Instantiation,  Prev: Destructors and Goto,  Up: C++ Extensions
  62. Declarations and Definitions in One Header
  63. ==========================================
  64.    C++ object definitions can be quite complex.  In principle, your
  65. source code will need two kinds of things for each object that you use
  66. across more than one source file.  First, you need an "interface"
  67. specification, describing its structure with type declarations and
  68. function prototypes.  Second, you need the "implementation" itself.  It
  69. can be tedious to maintain a separate interface description in a header
  70. file, in parallel to the actual implementation.  It is also dangerous,
  71. since separate interface and implementation definitions may not remain
  72. parallel.
  73.    With GNU C++, you can use a single header file for both purposes.
  74.      *Warning:* The mechanism to specify this is in transition.  For the
  75.      nonce, you must use one of two `#pragma' commands; in a future
  76.      release of GNU C++, an alternative mechanism will make these
  77.      `#pragma' commands unnecessary.
  78.    The header file contains the full definitions, but is marked with
  79. `#pragma interface' in the source code.  This allows the compiler to
  80. use the header file only as an interface specification when ordinary
  81. source files incorporate it with `#include'.  In the single source file
  82. where the full implementation belongs, you can use either a naming
  83. convention or `#pragma implementation' to indicate this alternate use
  84. of the header file.
  85. `#pragma interface'
  86. `#pragma interface "SUBDIR/OBJECTS.h"'
  87.      Use this directive in *header files* that define object classes,
  88.      to save space in most of the object files that use those classes.
  89.      Normally, local copies of certain information (backup copies of
  90.      inline member functions, debugging information, and the internal
  91.      tables that implement virtual functions) must be kept in each
  92.      object file that includes class definitions.  You can use this
  93.      pragma to avoid such duplication.  When a header file containing
  94.      `#pragma interface' is included in a compilation, this auxiliary
  95.      information will not be generated (unless the main input source
  96.      file itself uses `#pragma implementation').  Instead, the object
  97.      files will contain references to be resolved at link time.
  98.      The second form of this directive is useful for the case where you
  99.      have multiple headers with the same name in different directories.
  100.      If you use this form, you must specify the same string to `#pragma
  101.      implementation'.
  102. `#pragma implementation'
  103. `#pragma implementation "OBJECTS.h"'
  104.      Use this pragma in a *main input file*, when you want full output
  105.      from included header files to be generated (and made globally
  106.      visible).  The included header file, in turn, should use `#pragma
  107.      interface'.  Backup copies of inline member functions, debugging
  108.      information, and the internal tables used to implement virtual
  109.      functions are all generated in implementation files.
  110.      If you use `#pragma implementation' with no argument, it applies to
  111.      an include file with the same basename(1) as your source file.
  112.      For example, in `allclass.cc', `#pragma implementation' by itself
  113.      is equivalent to `#pragma implementation "allclass.h"'.
  114.      In versions of GNU C++ prior to 2.6.0 `allclass.h' was treated as
  115.      an implementation file whenever you would include it from
  116.      `allclass.cc' even if you never specified `#pragma
  117.      implementation'.  This was deemed to be more trouble than it was
  118.      worth, however, and disabled.
  119.      If you use an explicit `#pragma implementation', it must appear in
  120.      your source file *before* you include the affected header files.
  121.      Use the string argument if you want a single implementation file to
  122.      include code from multiple header files.  (You must also use
  123.      `#include' to include the header file; `#pragma implementation'
  124.      only specifies how to use the file--it doesn't actually include
  125.      it.)
  126.      There is no way to split up the contents of a single header file
  127.      into multiple implementation files.
  128.    `#pragma implementation' and `#pragma interface' also have an effect
  129. on function inlining.
  130.    If you define a class in a header file marked with `#pragma
  131. interface', the effect on a function defined in that class is similar to
  132. an explicit `extern' declaration--the compiler emits no code at all to
  133. define an independent version of the function.  Its definition is used
  134. only for inlining with its callers.
  135.    Conversely, when you include the same header file in a main source
  136. file that declares it as `#pragma implementation', the compiler emits
  137. code for the function itself; this defines a version of the function
  138. that can be found via pointers (or by callers compiled without
  139. inlining).  If all calls to the function can be inlined, you can avoid
  140. emitting the function by compiling with `-fno-implement-inlines'.  If
  141. any calls were not inlined, you will get linker errors.
  142.    ---------- Footnotes ----------
  143.    (1)  A file's "basename" was the name stripped of all leading path
  144. information and of trailing suffixes, such as `.h' or `.C' or `.cc'.
  145. File: gcc.info,  Node: Template Instantiation,  Next: C++ Signatures,  Prev: C++ Interface,  Up: C++ Extensions
  146. Where's the Template?
  147. =====================
  148.    C++ templates are the first language feature to require more
  149. intelligence from the environment than one usually finds on a UNIX
  150. system.  Somehow the compiler and linker have to make sure that each
  151. template instance occurs exactly once in the executable if it is needed,
  152. and not at all otherwise.  There are two basic approaches to this
  153. problem, which I will refer to as the Borland model and the Cfront
  154. model.
  155. Borland model
  156.      Borland C++ solved the template instantiation problem by adding
  157.      the code equivalent of common blocks to their linker; template
  158.      instances are emitted in each translation unit that uses them, and
  159.      they are collapsed together at run time.  The advantage of this
  160.      model is that the linker only has to consider the object files
  161.      themselves; there is no external complexity to worry about.  This
  162.      disadvantage is that compilation time is increased because the
  163.      template code is being compiled repeatedly.  Code written for this
  164.      model tends to include definitions of all member templates in the
  165.      header file, since they must be seen to be compiled.
  166. Cfront model
  167.      The AT&T C++ translator, Cfront, solved the template instantiation
  168.      problem by creating the notion of a template repository, an
  169.      automatically maintained place where template instances are
  170.      stored.  As individual object files are built, notes are placed in
  171.      the repository to record where templates and potential type
  172.      arguments were seen so that the subsequent instantiation step
  173.      knows where to find them.  At link time, any needed instances are
  174.      generated and linked in.  The advantages of this model are more
  175.      optimal compilation speed and the ability to use the system
  176.      linker; to implement the Borland model a compiler vendor also
  177.      needs to replace the linker.  The disadvantages are vastly
  178.      increased complexity, and thus potential for error; theoretically,
  179.      this should be just as transparent, but in practice it has been
  180.      very difficult to build multiple programs in one directory and one
  181.      program in multiple directories using Cfront.  Code written for
  182.      this model tends to separate definitions of non-inline member
  183.      templates into a separate file, which is magically found by the
  184.      link preprocessor when a template needs to be instantiated.
  185.    Currently, g++ implements neither automatic model.  The g++ team
  186. hopes to have a repository working for 2.7.0.  In the mean time, you
  187. have three options for dealing with template instantiations:
  188.   1. Do nothing.  Pretend g++ does implement automatic instantiation
  189.      management.  Code written for the Borland model will work fine, but
  190.      each translation unit will contain instances of each of the
  191.      templates it uses.  In a large program, this can lead to an
  192.      unacceptable amount of code duplication.
  193.   2. Add `#pragma interface' to all files containing template
  194.      definitions.  For each of these files, add `#pragma implementation
  195.      "FILENAME"' to the top of some `.C' file which `#include's it.
  196.      Then compile everything with -fexternal-templates.  The templates
  197.      will then only be expanded in the translation unit which
  198.      implements them (i.e. has a `#pragma implementation' line for the
  199.      file where they live); all other files will use external
  200.      references.  If you're lucky, everything should work properly.  If
  201.      you get undefined symbol errors, you need to make sure that each
  202.      template instance which is used in the program is used in the file
  203.      which implements that template.  If you don't have any use for a
  204.      particular instance in that file, you can just instantiate it
  205.      explicitly, using the syntax from the latest C++ working paper:
  206.           template class A<int>;
  207.           template ostream& operator << (ostream&, const A<int>&);
  208.      This strategy will work with code written for either model.  If
  209.      you are using code written for the Cfront model, the file
  210.      containing a class template and the file containing its member
  211.      templates should be implemented in the same translation unit.
  212.      A slight variation on this approach is to use the flag
  213.      -falt-external-templates instead; this flag causes template
  214.      instances to be emitted in the translation unit that implements
  215.      the header where they are first instantiated, rather than the one
  216.      which implements the file where the templates are defined.  This
  217.      header must be the same in all translation units, or things are
  218.      likely to break.
  219.      *Note Declarations and Definitions in One Header: C++ Interface,
  220.      for more discussion of these pragmas.
  221.   3. Explicitly instantiate all the template instances you use, and
  222.      compile with -fno-implicit-templates.  This is probably your best
  223.      bet; it may require more knowledge of exactly which templates you
  224.      are using, but it's less mysterious than the previous approach,
  225.      and it doesn't require any `#pragma's or other g++-specific code.
  226.      You can scatter the instantiations throughout your program, you
  227.      can create one big file to do all the instantiations, or you can
  228.      create tiny files like
  229.           #include "Foo.h"
  230.           #include "Foo.cc"
  231.           
  232.           template class Foo<int>;
  233.      for each instance you need, and create a template instantiation
  234.      library from those.  I'm partial to the last, but your mileage may
  235.      vary.  If you are using Cfront-model code, you can probably get
  236.      away with not using -fno-implicit-templates when compiling files
  237.      that don't `#include' the member template definitions.
  238. File: gcc.info,  Node: C++ Signatures,  Prev: Template Instantiation,  Up: C++ Extensions
  239. Type Abstraction using Signatures
  240. =================================
  241.    In GNU C++, you can use the keyword `signature' to define a
  242. completely abstract class interface as a datatype.  You can connect this
  243. abstraction with actual classes using signature pointers.  If you want
  244. to use signatures, run the GNU compiler with the `-fhandle-signatures'
  245. command-line option.  (With this option, the compiler reserves a second
  246. keyword `sigof' as well, for a future extension.)
  247.    Roughly, signatures are type abstractions or interfaces of classes.
  248. Some other languages have similar facilities.  C++ signatures are
  249. related to ML's signatures, Haskell's type classes, definition modules
  250. in Modula-2, interface modules in Modula-3, abstract types in Emerald,
  251. type modules in Trellis/Owl, categories in Scratchpad II, and types in
  252. POOL-I.  For a more detailed discussion of signatures, see `Signatures:
  253. A C++ Extension for Type Abstraction and Subtype Polymorphism' by
  254. Gerald Baumgartner and Vincent F. Russo (Tech report CSD-TR-93-059,
  255. Dept. of Computer Sciences, Purdue University, September 1993, to
  256. appear in *Software Practice & Experience*).  You can get the tech
  257. report by anonymous FTP from `ftp.cs.purdue.edu' in
  258. `pub/reports/TR93-059.PS.Z'.
  259.    Syntactically, a signature declaration is a collection of member
  260. function declarations and nested type declarations.  For example, this
  261. signature declaration defines a new abstract type `S' with member
  262. functions `int foo ()' and `int bar (int)':
  263.      signature S
  264.      {
  265.        int foo ();
  266.        int bar (int);
  267.      };
  268.    Since signature types do not include implementation definitions, you
  269. cannot write an instance of a signature directly.  Instead, you can
  270. define a pointer to any class that contains the required interfaces as a
  271. "signature pointer".  Such a class "implements" the signature type.
  272.    To use a class as an implementation of `S', you must ensure that the
  273. class has public member functions `int foo ()' and `int bar (int)'.
  274. The class can have other member functions as well, public or not; as
  275. long as it offers what's declared in the signature, it is suitable as
  276. an implementation of that signature type.
  277.    For example, suppose that `C' is a class that meets the requirements
  278. of signature `S' (`C' "conforms to" `S').  Then
  279.      C obj;
  280.      S * p = &obj;
  281. defines a signature pointer `p' and initializes it to point to an
  282. object of type `C'.  The member function call `int i = p->foo ();'
  283. executes `obj.foo ()'.
  284.    Abstract virtual classes provide somewhat similar facilities in
  285. standard C++.  There are two main advantages to using signatures
  286. instead:
  287.   1. Subtyping becomes independent from inheritance.  A class or
  288.      signature type `T' is a subtype of a signature type `S'
  289.      independent of any inheritance hierarchy as long as all the member
  290.      functions declared in `S' are also found in `T'.  So you can
  291.      define a subtype hierarchy that is completely independent from any
  292.      inheritance (implementation) hierarchy, instead of being forced to
  293.      use types that mirror the class inheritance hierarchy.
  294.   2. Signatures allow you to work with existing class hierarchies as
  295.      implementations of a signature type.  If those class hierarchies
  296.      are only available in compiled form, you're out of luck with
  297.      abstract virtual classes, since an abstract virtual class cannot
  298.      be retrofitted on top of existing class hierarchies.  So you would
  299.      be required to write interface classes as subtypes of the abstract
  300.      virtual class.
  301.    There is one more detail about signatures.  A signature declaration
  302. can contain member function *definitions* as well as member function
  303. declarations.  A signature member function with a full definition is
  304. called a *default implementation*; classes need not contain that
  305. particular interface in order to conform.  For example, a class `C' can
  306. conform to the signature
  307.      signature T
  308.      {
  309.        int f (int);
  310.        int f0 () { return f (0); };
  311.      };
  312. whether or not `C' implements the member function `int f0 ()'.  If you
  313. define `C::f0', that definition takes precedence; otherwise, the
  314. default implementation `S::f0' applies.
  315. File: gcc.info,  Node: Trouble,  Next: Bugs,  Prev: C++ Extensions,  Up: Top
  316. Known Causes of Trouble with GNU CC
  317. ***********************************
  318.    This section describes known problems that affect users of GNU CC.
  319. Most of these are not GNU CC bugs per se--if they were, we would fix
  320. them.  But the result for a user may be like the result of a bug.
  321.    Some of these problems are due to bugs in other software, some are
  322. missing features that are too much work to add, and some are places
  323. where people's opinions differ as to what is best.
  324. * Menu:
  325. * Actual Bugs::              Bugs we will fix later.
  326. * Installation Problems::     Problems that manifest when you install GNU CC.
  327. * Cross-Compiler Problems::   Common problems of cross compiling with GNU CC.
  328. * Interoperation::      Problems using GNU CC with other compilers,
  329.                and with certain linkers, assemblers and debuggers.
  330. * External Bugs::    Problems compiling certain programs.
  331. * Incompatibilities::   GNU CC is incompatible with traditional C.
  332. * Fixed Headers::       GNU C uses corrected versions of system header files.
  333.                            This is necessary, but doesn't always work smoothly.
  334. * Disappointments::     Regrettable things we can't change, but not quite bugs.
  335. * C++ Misunderstandings::     Common misunderstandings with GNU C++.
  336. * Protoize Caveats::    Things to watch out for when using `protoize'.
  337. * Non-bugs::        Things we think are right, but some others disagree.
  338. * Warnings and Errors:: Which problems in your code get warnings,
  339.                          and which get errors.
  340. File: gcc.info,  Node: Actual Bugs,  Next: Installation Problems,  Up: Trouble
  341. Actual Bugs We Haven't Fixed Yet
  342. ================================
  343.    * The `fixincludes' script interacts badly with automounters; if the
  344.      directory of system header files is automounted, it tends to be
  345.      unmounted while `fixincludes' is running.  This would seem to be a
  346.      bug in the automounter.  We don't know any good way to work around
  347.      it.
  348.    * The `fixproto' script will sometimes add prototypes for the
  349.      `sigsetjmp' and `siglongjmp' functions that reference the
  350.      `jmp_buf' type before that type is defined.  To work around this,
  351.      edit the offending file and place the typedef in front of the
  352.      prototypes.
  353.    * There are several obscure case of mis-using struct, union, and
  354.      enum tags that are not detected as errors by the compiler.
  355.    * When `-pedantic-errors' is specified, GNU C will incorrectly give
  356.      an error message when a function name is specified in an expression
  357.      involving the comma operator.
  358.    * Loop unrolling doesn't work properly for certain C++ programs.
  359.      This is a bug in the C++ front end.  It sometimes emits incorrect
  360.      debug info, and the loop unrolling code is unable to recover from
  361.      this error.
  362. File: gcc.info,  Node: Installation Problems,  Next: Cross-Compiler Problems,  Prev: Actual Bugs,  Up: Trouble
  363. Installation Problems
  364. =====================
  365.    This is a list of problems (and some apparent problems which don't
  366. really mean anything is wrong) that show up during installation of GNU
  367.    * On certain systems, defining certain environment variables such as
  368.      `CC' can interfere with the functioning of `make'.
  369.    * If you encounter seemingly strange errors when trying to build the
  370.      compiler in a directory other than the source directory, it could
  371.      be because you have previously configured the compiler in the
  372.      source directory.  Make sure you have done all the necessary
  373.      preparations.  *Note Other Dir::.
  374.    * If you build GNU CC on a BSD system using a directory stored in a
  375.      System V file system, problems may occur in running `fixincludes'
  376.      if the System V file system doesn't support symbolic links.  These
  377.      problems result in a failure to fix the declaration of `size_t' in
  378.      `sys/types.h'.  If you find that `size_t' is a signed type and
  379.      that type mismatches occur, this could be the cause.
  380.      The solution is not to use such a directory for building GNU CC.
  381.    * In previous versions of GNU CC, the `gcc' driver program looked for
  382.      `as' and `ld' in various places; for example, in files beginning
  383.      with `/usr/local/lib/gcc-'.  GNU CC version 2 looks for them in
  384.      the directory `/usr/local/lib/gcc-lib/TARGET/VERSION'.
  385.      Thus, to use a version of `as' or `ld' that is not the system
  386.      default, for example `gas' or GNU `ld', you must put them in that
  387.      directory (or make links to them from that directory).
  388.    * Some commands executed when making the compiler may fail (return a
  389.      non-zero status) and be ignored by `make'.  These failures, which
  390.      are often due to files that were not found, are expected, and can
  391.      safely be ignored.
  392.    * It is normal to have warnings in compiling certain files about
  393.      unreachable code and about enumeration type clashes.  These files'
  394.      names begin with `insn-'.  Also, `real.c' may get some warnings
  395.      that you can ignore.
  396.    * Sometimes `make' recompiles parts of the compiler when installing
  397.      the compiler.  In one case, this was traced down to a bug in
  398.      `make'.  Either ignore the problem or switch to GNU Make.
  399.    * If you have installed a program known as purify, you may find that
  400.      it causes errors while linking `enquire', which is part of building
  401.      GNU CC.  The fix is to get rid of the file `real-ld' which purify
  402.      installs--so that GNU CC won't try to use it.
  403.    * On Linux SLS 1.01, there is a problem with `libc.a': it does not
  404.      contain the obstack functions.  However, GNU CC assumes that the
  405.      obstack functions are in `libc.a' when it is the GNU C library.
  406.      To work around this problem, change the `__GNU_LIBRARY__'
  407.      conditional around line 31 to `#if 1'.
  408.    * On some 386 systems, building the compiler never finishes because
  409.      `enquire' hangs due to a hardware problem in the motherboard--it
  410.      reports floating point exceptions to the kernel incorrectly.  You
  411.      can install GNU CC except for `float.h' by patching out the
  412.      command to run `enquire'.  You may also be able to fix the problem
  413.      for real by getting a replacement motherboard.  This problem was
  414.      observed in Revision E of the Micronics motherboard, and is fixed
  415.      in Revision F.  It has also been observed in the MYLEX MXA-33
  416.      motherboard.
  417.      If you encounter this problem, you may also want to consider
  418.      removing the FPU from the socket during the compilation.
  419.      Alternatively, if you are running SCO Unix, you can reboot and
  420.      force the FPU to be ignored.  To do this, type `hd(40)unix auto
  421.      ignorefpu'.
  422.    * On some 386 systems, GNU CC crashes trying to compile `enquire.c'.
  423.      This happens on machines that don't have a 387 FPU chip.  On 386
  424.      machines, the system kernel is supposed to emulate the 387 when you
  425.      don't have one.  The crash is due to a bug in the emulator.
  426.      One of these systems is the Unix from Interactive Systems: 386/ix.
  427.      On this system, an alternate emulator is provided, and it does
  428.      work.  To use it, execute this command as super-user:
  429.           ln /etc/emulator.rel1 /etc/emulator
  430.      and then reboot the system.  (The default emulator file remains
  431.      present under the name `emulator.dflt'.)
  432.      Try using `/etc/emulator.att', if you have such a problem on the
  433.      SCO system.
  434.      Another system which has this problem is Esix.  We don't know
  435.      whether it has an alternate emulator that works.
  436.      On NetBSD 0.8, a similar problem manifests itself as these error
  437.      messages:
  438.           enquire.c: In function `fprop':
  439.           enquire.c:2328: floating overflow
  440.    * On SCO systems, when compiling GNU CC with the system's compiler,
  441.      do not use `-O'.  Some versions of the system's compiler miscompile
  442.      GNU CC with `-O'.
  443.    * Sometimes on a Sun 4 you may observe a crash in the program
  444.      `genflags' or `genoutput' while building GNU CC.  This is said to
  445.      be due to a bug in `sh'.  You can probably get around it by running
  446.      `genflags' or `genoutput' manually and then retrying the `make'.
  447.    * On Solaris 2, executables of GNU CC version 2.0.2 are commonly
  448.      available, but they have a bug that shows up when compiling current
  449.      versions of GNU CC: undefined symbol errors occur during assembly
  450.      if you use `-g'.
  451.      The solution is to compile the current version of GNU CC without
  452.      `-g'.  That makes a working compiler which you can use to recompile
  453.      with `-g'.
  454.    * Solaris 2 comes with a number of optional OS packages.  Some of
  455.      these packages are needed to use GNU CC fully.  If you did not
  456.      install all optional packages when installing Solaris, you will
  457.      need to verify that the packages that GNU CC needs are installed.
  458.      To check whether an optional package is installed, use the
  459.      `pkginfo' command.  To add an optional package, use the `pkgadd'
  460.      command.  For further details, see the Solaris documentation.
  461.      For Solaris 2.0 and 2.1, GNU CC needs six packages: `SUNWarc',
  462.      `SUNWbtool', `SUNWesu', `SUNWhea', `SUNWlibm', and `SUNWtoo'.
  463.      For Solaris 2.2, GNU CC needs an additional seventh package:
  464.      `SUNWsprot'.
  465.    * On Solaris 2, trying to use the linker and other tools in
  466.      `/usr/ucb' to install GNU CC has been observed to cause trouble.
  467.      For example, the linker may hang indefinitely.  The fix is to
  468.      remove `/usr/ucb' from your `PATH'.
  469.    * If you use the 1.31 version of the MIPS assembler (such as was
  470.      shipped with Ultrix 3.1), you will need to use the
  471.      -fno-delayed-branch switch when optimizing floating point code.
  472.      Otherwise, the assembler will complain when the GCC compiler fills
  473.      a branch delay slot with a floating point instruction, such as
  474.      `add.d'.
  475.    * If on a MIPS system you get an error message saying "does not have
  476.      gp sections for all it's [sic] sectons [sic]", don't worry about
  477.      it.  This happens whenever you use GAS with the MIPS linker, but
  478.      there is not really anything wrong, and it is okay to use the
  479.      output file.  You can stop such warnings by installing the GNU
  480.      linker.
  481.      It would be nice to extend GAS to produce the gp tables, but they
  482.      are optional, and there should not be a warning about their
  483.      absence.
  484.    * In Ultrix 4.0 on the MIPS machine, `stdio.h' does not work with GNU
  485.      CC at all unless it has been fixed with `fixincludes'.  This causes
  486.      problems in building GNU CC.  Once GNU CC is installed, the
  487.      problems go away.
  488.      To work around this problem, when making the stage 1 compiler,
  489.      specify this option to Make:
  490.           GCC_FOR_TARGET="./xgcc -B./ -I./include"
  491.      When making stage 2 and stage 3, specify this option:
  492.           CFLAGS="-g -I./include"
  493.    * Users have reported some problems with version 2.0 of the MIPS
  494.      compiler tools that were shipped with Ultrix 4.1.  Version 2.10
  495.      which came with Ultrix 4.2 seems to work fine.
  496.      Users have also reported some problems with version 2.20 of the
  497.      MIPS compiler tools that were shipped with RISC/os 4.x.  The
  498.      earlier version 2.11 seems to work fine.
  499.    * Some versions of the MIPS linker will issue an assertion failure
  500.      when linking code that uses `alloca' against shared libraries on
  501.      RISC-OS 5.0, and DEC's OSF/1 systems.  This is a bug in the
  502.      linker, that is supposed to be fixed in future revisions.  To
  503.      protect against this, GNU CC passes `-non_shared' to the linker
  504.      unless you pass an explicit `-shared' or `-call_shared' switch.
  505.    * On System V release 3, you may get this error message while
  506.      linking:
  507.           ld fatal: failed to write symbol name SOMETHING
  508.            in strings table for file WHATEVER
  509.      This probably indicates that the disk is full or your ULIMIT won't
  510.      allow the file to be as large as it needs to be.
  511.      This problem can also result because the kernel parameter `MAXUMEM'
  512.      is too small.  If so, you must regenerate the kernel and make the
  513.      value much larger.  The default value is reported to be 1024; a
  514.      value of 32768 is said to work.  Smaller values may also work.
  515.    * On System V, if you get an error like this,
  516.           /usr/local/lib/bison.simple: In function `yyparse':
  517.           /usr/local/lib/bison.simple:625: virtual memory exhausted
  518.      that too indicates a problem with disk space, ULIMIT, or `MAXUMEM'.
  519.    * Current GNU CC versions probably do not work on version 2 of the
  520.      NeXT operating system.
  521.    * On NeXTStep 3.0, the Objective C compiler does not work, due,
  522.      apparently, to a kernel bug that it happens to trigger.  This
  523.      problem does not happen on 3.1.
  524.    * On the Tower models 4N0 and 6N0, by default a process is not
  525.      allowed to have more than one megabyte of memory.  GNU CC cannot
  526.      compile itself (or many other programs) with `-O' in that much
  527.      memory.
  528.      To solve this problem, reconfigure the kernel adding the following
  529.      line to the configuration file:
  530.           MAXUMEM = 4096
  531.    * On HP 9000 series 300 or 400 running HP-UX release 8.0, there is a
  532.      bug in the assembler that must be fixed before GNU CC can be
  533.      built.  This bug manifests itself during the first stage of
  534.      compilation, while building `libgcc2.a':
  535.           _floatdisf
  536.           cc1: warning: `-g' option not supported on this version of GCC
  537.           cc1: warning: `-g1' option not supported on this version of GCC
  538.           ./xgcc: Internal compiler error: program as got fatal signal 11
  539.      A patched version of the assembler is available by anonymous ftp
  540.      from `altdorf.ai.mit.edu' as the file
  541.      `archive/cph/hpux-8.0-assembler'.  If you have HP software support,
  542.      the patch can also be obtained directly from HP, as described in
  543.      the following note:
  544.           This is the patched assembler, to patch SR#1653-010439, where
  545.           the assembler aborts on floating point constants.
  546.           The bug is not really in the assembler, but in the shared
  547.           library version of the function "cvtnum(3c)".  The bug on
  548.           "cvtnum(3c)" is SR#4701-078451.  Anyway, the attached
  549.           assembler uses the archive library version of "cvtnum(3c)"
  550.           and thus does not exhibit the bug.
  551.      This patch is also known as PHCO_4484.
  552.    * On HP-UX version 8.05, but not on 8.07 or more recent versions,
  553.      the `fixproto' shell script triggers a bug in the system shell.
  554.      If you encounter this problem, upgrade your operating system or
  555.      use BASH (the GNU shell) to run `fixproto'.
  556.    * Some versions of the Pyramid C compiler are reported to be unable
  557.      to compile GNU CC.  You must use an older version of GNU CC for
  558.      bootstrapping.  One indication of this problem is if you get a
  559.      crash when GNU CC compiles the function `muldi3' in file
  560.      `libgcc2.c'.
  561.      You may be able to succeed by getting GNU CC version 1, installing
  562.      it, and using it to compile GNU CC version 2.  The bug in the
  563.      Pyramid C compiler does not seem to affect GNU CC version 1.
  564.    * There may be similar problems on System V Release 3.1 on 386
  565.      systems.
  566.    * On the Intel Paragon (an i860 machine), if you are using operating
  567.      system version 1.0, you will get warnings or errors about
  568.      redefinition of `va_arg' when you build GNU CC.
  569.      If this happens, then you need to link most programs with the
  570.      library `iclib.a'.  You must also modify `stdio.h' as follows:
  571.      before the lines
  572.           #if     defined(__i860__) && !defined(_VA_LIST)
  573.           #include <va_list.h>
  574.      insert the line
  575.           #if __PGC__
  576.      and after the lines
  577.           extern int  vprintf(const char *, va_list );
  578.           extern int  vsprintf(char *, const char *, va_list );
  579.           #endif
  580.      insert the line
  581.           #endif /* __PGC__ */
  582.      These problems don't exist in operating system version 1.1.
  583.    * On the Altos 3068, programs compiled with GNU CC won't work unless
  584.      you fix a kernel bug.  This happens using system versions V.2.2
  585.      1.0gT1 and V.2.2 1.0e and perhaps later versions as well.  See the
  586.      file `README.ALTOS'.
  587.    * You will get several sorts of compilation and linking errors on the
  588.      we32k if you don't follow the special instructions.  *Note
  589.      Configurations::.
  590.    * A bug in the HP-UX 8.05 (and earlier) shell will cause the fixproto
  591.      program to report an error of the form:
  592.           ./fixproto: sh internal 1K buffer overflow
  593.      To fix this, change the first line of the fixproto script to look
  594.      like:
  595.           #!/bin/ksh
  596. File: gcc.info,  Node: Cross-Compiler Problems,  Next: Interoperation,  Prev: Installation Problems,  Up: Trouble
  597. Cross-Compiler Problems
  598. =======================
  599.    You may run into problems with cross compilation on certain machines,
  600. for several reasons.
  601.    * Cross compilation can run into trouble for certain machines because
  602.      some target machines' assemblers require floating point numbers to
  603.      be written as *integer* constants in certain contexts.
  604.      The compiler writes these integer constants by examining the
  605.      floating point value as an integer and printing that integer,
  606.      because this is simple to write and independent of the details of
  607.      the floating point representation.  But this does not work if the
  608.      compiler is running on a different machine with an incompatible
  609.      floating point format, or even a different byte-ordering.
  610.      In addition, correct constant folding of floating point values
  611.      requires representing them in the target machine's format.  (The C
  612.      standard does not quite require this, but in practice it is the
  613.      only way to win.)
  614.      It is now possible to overcome these problems by defining macros
  615.      such as `REAL_VALUE_TYPE'.  But doing so is a substantial amount of
  616.      work for each target machine.  *Note Cross-compilation::.
  617.    * At present, the program `mips-tfile' which adds debug support to
  618.      object files on MIPS systems does not work in a cross compile
  619.      environment.
  620. File: gcc.info,  Node: Interoperation,  Next: External Bugs,  Prev: Cross-Compiler Problems,  Up: Trouble
  621. Interoperation
  622. ==============
  623.    This section lists various difficulties encountered in using GNU C or
  624. GNU C++ together with other compilers or with the assemblers, linkers,
  625. libraries and debuggers on certain systems.
  626.    * Objective C does not work on the RS/6000.
  627.    * GNU C++ does not do name mangling in the same way as other C++
  628.      compilers.  This means that object files compiled with one compiler
  629.      cannot be used with another.
  630.      This effect is intentional, to protect you from more subtle
  631.      problems.  Compilers differ as to many internal details of C++
  632.      implementation, including: how class instances are laid out, how
  633.      multiple inheritance is implemented, and how virtual function
  634.      calls are handled.  If the name encoding were made the same, your
  635.      programs would link against libraries provided from other
  636.      compilers--but the programs would then crash when run.
  637.      Incompatible libraries are then detected at link time, rather than
  638.      at run time.
  639.    * Older GDB versions sometimes fail to read the output of GNU CC
  640.      version 2.  If you have trouble, get GDB version 4.4 or later.
  641.    * DBX rejects some files produced by GNU CC, though it accepts
  642.      similar constructs in output from PCC.  Until someone can supply a
  643.      coherent description of what is valid DBX input and what is not,
  644.      there is nothing I can do about these problems.  You are on your
  645.      own.
  646.    * The GNU assembler (GAS) does not support PIC.  To generate PIC
  647.      code, you must use some other assembler, such as `/bin/as'.
  648.    * On some BSD systems, including some versions of Ultrix, use of
  649.      profiling causes static variable destructors (currently used only
  650.      in C++) not to be run.
  651.    * Use of `-I/usr/include' may cause trouble.
  652.      Many systems come with header files that won't work with GNU CC
  653.      unless corrected by `fixincludes'.  The corrected header files go
  654.      in a new directory; GNU CC searches this directory before
  655.      `/usr/include'.  If you use `-I/usr/include', this tells GNU CC to
  656.      search `/usr/include' earlier on, before the corrected headers.
  657.      The result is that you get the uncorrected header files.
  658.      Instead, you should use these options (when compiling C programs):
  659.           -I/usr/local/lib/gcc-lib/TARGET/VERSION/include -I/usr/include
  660.      For C++ programs, GNU CC also uses a special directory that
  661.      defines C++ interfaces to standard C subroutines.  This directory
  662.      is meant to be searched *before* other standard include
  663.      directories, so that it takes precedence.  If you are compiling
  664.      C++ programs and specifying include directories explicitly, use
  665.      this option first, then the two options above:
  666.           -I/usr/local/lib/g++-include
  667.    * On some SGI systems, when you use `-lgl_s' as an option, it gets
  668.      translated magically to `-lgl_s -lX11_s -lc_s'.  Naturally, this
  669.      does not happen when you use GNU CC.  You must specify all three
  670.      options explicitly.
  671.    * On a Sparc, GNU CC aligns all values of type `double' on an 8-byte
  672.      boundary, and it expects every `double' to be so aligned.  The Sun
  673.      compiler usually gives `double' values 8-byte alignment, with one
  674.      exception: function arguments of type `double' may not be aligned.
  675.      As a result, if a function compiled with Sun CC takes the address
  676.      of an argument of type `double' and passes this pointer of type
  677.      `double *' to a function compiled with GNU CC, dereferencing the
  678.      pointer may cause a fatal signal.
  679.      One way to solve this problem is to compile your entire program
  680.      with GNU CC.  Another solution is to modify the function that is
  681.      compiled with Sun CC to copy the argument into a local variable;
  682.      local variables are always properly aligned.  A third solution is
  683.      to modify the function that uses the pointer to dereference it via
  684.      the following function `access_double' instead of directly with
  685.      `*':
  686.           inline double
  687.           access_double (double *unaligned_ptr)
  688.           {
  689.             union d2i { double d; int i[2]; };
  690.           
  691.             union d2i *p = (union d2i *) unaligned_ptr;
  692.             union d2i u;
  693.           
  694.             u.i[0] = p->i[0];
  695.             u.i[1] = p->i[1];
  696.           
  697.             return u.d;
  698.           }
  699.      Storing into the pointer can be done likewise with the same union.
  700.    * On Solaris, the `malloc' function in the `libmalloc.a' library may
  701.      allocate memory that is only 4 byte aligned.  Since GNU CC on the
  702.      Sparc assumes that doubles are 8 byte aligned, this may result in a
  703.      fatal signal if doubles are stored in memory allocated by the
  704.      `libmalloc.a' library.
  705.      The solution is to not use the `libmalloc.a' library.  Use instead
  706.      `malloc' and related functions from `libc.a'; they do not have
  707.      this problem.
  708.    * Sun forgot to include a static version of `libdl.a' with some
  709.      versions of SunOS (mainly 4.1).  This results in undefined symbols
  710.      when linking static binaries (that is, if you use `-static').  If
  711.      you see undefined symbols `_dlclose', `_dlsym' or `_dlopen' when
  712.      linking, compile and link against the file `mit/util/misc/dlsym.c'
  713.      from the MIT version of X windows.
  714.    * The 128-bit long double format that the Sparc port supports
  715.      currently works by using the architecturally defined quad-word
  716.      floating point instructions.  Since there is no hardware that
  717.      supports these instructions they must be emulated by the operating
  718.      system.  Long doubles do not work in Sun OS versions 4.0.3 and
  719.      earlier, because the kernel eumulator uses an obsolete and
  720.      incompatible format.  Long doubles do not work in Sun OS versions
  721.      4.1.1 to 4.1.3 because of emululator bugs that cause random
  722.      unpredicatable failures.  Long doubles appear to work in Sun OS 5.x
  723.      (Solaris 2.x).
  724.    * On HP-UX version 9.01 on the HP PA, the HP compiler `cc' does not
  725.      compile GNU CC correctly.  We do not yet know why.  However, GNU CC
  726.      compiled on earlier HP-UX versions works properly on HP-UX 9.01
  727.      and can compile itself properly on 9.01.
  728.    * On the HP PA machine, ADB sometimes fails to work on functions
  729.      compiled with GNU CC.  Specifically, it fails to work on functions
  730.      that use `alloca' or variable-size arrays.  This is because GNU CC
  731.      doesn't generate HP-UX unwind descriptors for such functions.  It
  732.      may even be impossible to generate them.
  733.    * Debugging (`-g') is not supported on the HP PA machine, unless you
  734.      use the preliminary GNU tools (*note Installation::.).
  735.    * Taking the address of a label may generate errors from the HP-UX
  736.      PA assembler.  GAS for the PA does not have this problem.
  737.    * Using floating point parameters for indirect calls to static
  738.      functions will not work when using the HP assembler.  There simply
  739.      is no way for GCC to specify what registers hold arguments for
  740.      static functions when using the HP assembler.  GAS for the PA does
  741.      not have this problem.
  742.    * For some very large functions you may receive errors from the HP
  743.      linker complaining about an out of bounds unconditional branch
  744.      offset.  Fixing this problem correctly requires fixing problems in
  745.      GNU CC and GAS.  We hope to fix this in time for GNU CC 2.6.
  746.      Until then you can work around by making your function smaller,
  747.      and if you are using GAS, splitting the function into multiple
  748.      source files may be necessary.
  749.    * GNU CC compiled code sometimes emits warnings from the HP-UX
  750.      assembler of the form:
  751.           (warning) Use of GR3 when
  752.             frame >= 8192 may cause conflict.
  753.      These warnings are harmless and can be safely ignored.
  754.    * The current version of the assembler (`/bin/as') for the RS/6000
  755.      has certain problems that prevent the `-g' option in GCC from
  756.      working.  Note that `Makefile.in' uses `-g' by default when
  757.      compiling `libgcc2.c'.
  758.      IBM has produced a fixed version of the assembler.  The upgraded
  759.      assembler unfortunately was not included in any of the AIX 3.2
  760.      update PTF releases (3.2.2, 3.2.3, or 3.2.3e).  Users of AIX 3.1
  761.      should request PTF U403044 from IBM and users of AIX 3.2 should
  762.      request PTF U416277.  See the file `README.RS6000' for more
  763.      details on these updates.
  764.      You can test for the presense of a fixed assembler by using the
  765.      command
  766.           as -u < /dev/null
  767.      If the command exits normally, the assembler fix already is
  768.      installed.  If the assembler complains that "-u" is an unknown
  769.      flag, you need to order the fix.
  770.    * On the IBM RS/6000, compiling code of the form
  771.           extern int foo;
  772.           
  773.           ... foo ...
  774.           
  775.           static int foo;
  776.      will cause the linker to report an undefined symbol `foo'.
  777.      Although this behavior differs from most other systems, it is not a
  778.      bug because redefining an `extern' variable as `static' is
  779.      undefined in ANSI C.
  780.    * AIX on the RS/6000 provides support (NLS) for environments outside
  781.      of the United States.  Compilers and assemblers use NLS to support
  782.      locale-specific representations of various objects including
  783.      floating-point numbers ("." vs "," for separating decimal
  784.      fractions).  There have been problems reported where the library
  785.      linked with GCC does not produce the same floating-point formats
  786.      that the assembler accepts.  If you have this problem, set the
  787.      LANG environment variable to "C" or "En_US".
  788.    * Even if you specify `-fdollars-in-identifiers', you cannot
  789.      successfully use `$' in identifiers on the RS/6000 due to a
  790.      restriction in the IBM assembler.  GAS supports these identifiers.
  791.    * On the RS/6000, XLC version 1.3.0.0 will miscompile `jump.c'.  XLC
  792.      version 1.3.0.1 or later fixes this problem.  You can obtain
  793.      XLC-1.3.0.2 by requesting PTF 421749 from IBM.
  794.    * There is an assembler bug in versions of DG/UX prior to 5.4.2.01
  795.      that occurs when the `fldcr' instruction is used.  GNU CC uses
  796.      `fldcr' on the 88100 to serialize volatile memory references.  Use
  797.      the option `-mno-serialize-volatile' if your version of the
  798.      assembler has this bug.
  799.    * On VMS, GAS versions 1.38.1 and earlier may cause spurious warning
  800.      messages from the linker.  These warning messages complain of
  801.      mismatched psect attributes.  You can ignore them.  *Note VMS
  802.      Install::.
  803.    * On NewsOS version 3, if you include both of the files `stddef.h'
  804.      and `sys/types.h', you get an error because there are two typedefs
  805.      of `size_t'.  You should change `sys/types.h' by adding these
  806.      lines around the definition of `size_t':
  807.           #ifndef _SIZE_T
  808.           #define _SIZE_T
  809.           ACTUAL TYPEDEF HERE
  810.           #endif
  811.    * On the Alliant, the system's own convention for returning
  812.      structures and unions is unusual, and is not compatible with GNU
  813.      CC no matter what options are used.
  814.    * On the IBM RT PC, the MetaWare HighC compiler (hc) uses a different
  815.      convention for structure and union returning.  Use the option
  816.      `-mhc-struct-return' to tell GNU CC to use a convention compatible
  817.      with it.
  818.    * On Ultrix, the Fortran compiler expects registers 2 through 5 to
  819.      be saved by function calls.  However, the C compiler uses
  820.      conventions compatible with BSD Unix: registers 2 through 5 may be
  821.      clobbered by function calls.
  822.      GNU CC uses the same convention as the Ultrix C compiler.  You can
  823.      use these options to produce code compatible with the Fortran
  824.      compiler:
  825.           -fcall-saved-r2 -fcall-saved-r3 -fcall-saved-r4 -fcall-saved-r5
  826.    * On the WE32k, you may find that programs compiled with GNU CC do
  827.      not work with the standard shared C ilbrary.  You may need to link
  828.      with the ordinary C compiler.  If you do so, you must specify the
  829.      following options:
  830.           -L/usr/local/lib/gcc-lib/we32k-att-sysv/2.6.0 -lgcc -lc_s
  831.      The first specifies where to find the library `libgcc.a' specified
  832.      with the `-lgcc' option.
  833.      GNU CC does linking by invoking `ld', just as `cc' does, and there
  834.      is no reason why it *should* matter which compilation program you
  835.      use to invoke `ld'.  If someone tracks this problem down, it can
  836.      probably be fixed easily.
  837.    * On the Alpha, you may get assembler errors about invalid syntax as
  838.      a result of floating point constants.  This is due to a bug in the
  839.      C library functions `ecvt', `fcvt' and `gcvt'.  Given valid
  840.      floating point numbers, they sometimes print `NaN'.
  841.    * On Irix 4.0.5F (and perhaps in some other versions), an assembler
  842.      bug sometimes reorders instructions incorrectly when optimization
  843.      is turned on.  If you think this may be happening to you, try
  844.      using the GNU assembler; GAS version 2.1 supports ECOFF on Irix.
  845.      Or use the `-noasmopt' option when you compile GNU CC with itself,
  846.      and then again when you compile your program.  (This is a temporary
  847.      kludge to turn off assembler optimization on Irix.)  If this
  848.      proves to be what you need, edit the assembler spec in the file
  849.      `specs' so that it unconditionally passes `-O0' to the assembler,
  850.      and never passes `-O2' or `-O3'.
  851.